<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('收发类别')" />

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <div class="layui-inline">
                        <label class="layui-form-label">类型名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="d1" name="ddlx" placeholder="类型名称"/>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">订单分类</label>

                        <!--<select name="fl" id="flSelect" lay-search>-->
                        <!--</select>-->
                        <select name="fl">
                            <option value=""></option>
                            <option value="">全部</option>
                            <option value="0">入库单</option>
                            <option value="1">出库单</option>
                        </select>
                    </div>

                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal search_btn" lay-event="searchEvent" data-type="reload">查询</a>
                    </div>
                    <div class="layui-inline inline-reset-btn">
                        <button type="reset" class="layui-btn layui-btn-normal" >重置</button>
                    </div>
                </form>
                <!--顶部按钮展示区域 【 tpl-button 】 -->
                <div class="group-button tpl-button" id="toolbar"></div>
                <!--列表-->
                <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table" class="table text-nowrap"></table>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>

</body>


<div th:include="public/public_js::public_js"></div>
<div th:include="public/public_btn::public_btn"></div>
<script th:inline="javascript">
    var functions = [[${functions}]];
    layui.use(['list', 'layer', 'zzpUtils', 'jquery', 'laydate', 'tablebutton'], function () {

        var zzpUtils= layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate,
            tablebtn = layui.tablebutton;
        tablebtn.buildOnClick({
            type: 1,
            temp: $("#function_tpl"),
            functions: functions.headBtn,
            row: null,
            event: {
                searchEvent: function(){
                    zzpUtils.refreshTable("#table");
                },
                /*新增*/
                addEvent: function (data) {
                    add();
                },
                /*编辑*/
                editEvent: function (data) {
                    if (data.row != undefined) {
                        editDialog(data.row.id);
                    }
                },

            }
        });
        //初始化
        zzpUtils.webSocket.init();
        //新增
        function add() {
            zzpUtils.dialog({
                title: "新增收发类别",
                type: 2,
                content: "/base/SendReceiveCategory/add",
                area: ['50%', '65%'], //设置dialog大小，也可以不设置，
                end: function () {//增加成功后刷新
                    zzpUtils.refreshTable("#table");
                }
            });
        }

        function editDialog(id) {
            localStorage.id = id;
            console.log(id)
            zzpUtils.dialog({
                title: "编辑收发类别",
                type: 2,
                content: "/base/SendReceiveCategory/editCategory?id=" + id,
                area: ['50%', '70%'], //设置dialog大小，也可以不设置，
                end: function () {//修改成功后刷新
                    zzpUtils.refreshTable("#table");
                }
            });
        }

        laydate.render({
            elem: '#test5'
            ,theme: '#20a0ff'
        });
        //查询字典表中的数据 订单分类
        zzpUtils.select({
            elem:"#flSelect",    //dom
            url:"/sysdictionary/getSysdictionary/wms_owner_ordertype_fl"
            //路径 以"/"开头，后边正常字典路径
        });
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            isOperate: true,
           //functions: functions.tableBtn,
            pagination: true,
            url: '/wmsOwnerOrderType/list',
            columns: [
            //     {
            //     field: '',
            //     checkbox: true
            // },
                {
                field: 'mc',
                title: '货主名称'
            }, {
                field: 'ddlx',
                title: '类型名称'
            }, {
                field: 'show_fl',
                title: '订单分类'
            },{
                field: 'show_sfzj',
                title: '质检'
            }
            ],
            queryParams: function () {//查询条件
                return  zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            },
            /*定义表格右侧按钮*/
            operateFormatter: operateFormatter

        });
        /*表格右侧按钮*/
       // function operateFormatter(value, row, index) {
       //      var button = '<a class="tooltip2" id="tooltip' + row.id + '" data-tooltip-content="#tool' + row.id + '" id="btn_start"><i class="layui-icon layui-icon-more"></i></a>'
       //          + '<div class="tooltip_templates">'
       //          + '<span id="tool' + row.id + '">';
       //      for (var i = 0; i < functions.tableBtn.length; i++) {
       //          var btn = '<a class="layui-btn layui-btn-sm layui-btn-warm" lay-event="' + functions.tableBtn[i].event + '">'
       //              + functions.tableBtn[i].name
       //              + '</a>';
       //          button += btn;
       //      }
       //      button += '</span>'
       //          + '</div>';
       //      return button;
       //  }


        function operateFormatter(value, row, index) {
            var btn = '', button = '', buttons1 = '', buttons2 = '';
            for (var i = 0; i < functions.tableBtn.length; i++) {
                var item = functions.tableBtn[i];
                //更多之外
                buttons1 += '<button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="' + item.event + '">'
                    + item.name
                    + '</button>';
            }

            return buttons1;
        }
    });
</script>
</html>